<?php

namespace app\common\lib;

class ClassArr
{
    public static function smsClassStat()
    {
        return [
            "ali" => "app\common\lib\sms\AliSms",
            "baidu" => "app\common\lib\sms\BaiduSms",
            "jd" => "app\common\lib\sms\JdSms",
        ];
    }

    public static function uploadClassStat()
    {
        return [
            'text' => 'xxx',
            'image' => 'xxx',
        ];
    }

    /**
     * 工厂封装
     * @param $type
     * @param $class
     * @param  array  $params
     * @param  false  $needInstance
     * @return false|mixed|object
     * @throws \ReflectionException
     */
    public static function initClass($type, $class,$params = [], $needInstance = false)
    {
        if (!array_key_exists($type, $class)) {
            return false;
        }
        $className = $class[$type];
        return $needInstance == true ? (new \ReflectionClass($className))->newInstanceArgs($params) : $className;
    }
}